

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Testhomework {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Scanner sc = new Scanner(System.in);


        System.out.println("您好，欢迎使用一起帮智能工具（按回车键继续）........");
        String s1 = sc.nextLine();


        System.out.println("按出回车键弹出菜单...");
        String s2 = sc.nextLine();
        int choice = 0;
        while (true) {
            if (choice == 3) {
                break;
            }
            System.out.println("1.检查作业");
            System.out.println("2.奖励");
            System.out.println("3.退出菜单");
            System.out.println("请输入你的选择");
            choice = sc.nextInt();

            switch (choice) {
                case 1:
                    Map<String, Integer> map = new HashMap<>();
                    String stuNo = "";
                    //字符流的方式读文件
                    String path = "D:\\names.txt";

                    BufferedReader reader = null;
                    try {
                        reader = new BufferedReader(new FileReader(path));

                        while ((stuNo = reader.readLine()) != null) {
                            map.put(stuNo, 0);
                        }
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } finally {
                        try {
                            reader.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                    File file = new File("D:\\16信本2班java作业一");
                    File[] files = file.listFiles();
                    //遍历
                    for (File f : files) {
                        String fileName = f.getName();
                        //保存提取到学号
                        String no = "";
                        //从文件名中提取学号
                        //正则表达式：1模板，2三个填空
                        Matcher matcher = Pattern.compile("信本2班(\\d+)").matcher(fileName);
                        while (matcher.find()) {

                            no = matcher.group(1);
                        }

                        map.put(no, 1);
                    }
                    //把value为0的打印出来
                    //遍历一个map
                    System.out.println("以下同学没有交作业，请提醒下列同学交作业");
                    for (Map.Entry<String, Integer> entry : map.entrySet()) {
                        if (entry.getValue() == 0) {
                            System.out.println(entry.getKey());
                        }
                    }

                    System.out.println("按回车继续");
                    String s3= scanner.nextLine();
                    break;

                case 2:


                    System.out.println("恭喜你，作业完成很好！以下是为您准备的奖励（按回车键继续）...");
                    String s4 = scanner.nextLine();
                    System.out.println("祝贺你，获得了免费旅游服务的资格，下面我们为您计算旅游的资金（按回车键继续）...");
                    String s5 = scanner.nextLine();

                    System.out.println("请输入你要去哪个省份旅游（按回车键显示省份）.....");
                    String s6 = sc.nextLine();
                    Map<String, Integer> map1 = new HashMap<>();

                    try {
                        BufferedReader reader1 = new BufferedReader(new FileReader("D://javaidea.txt"));
                        while (true) {
                            String s = reader1.readLine();
                            if (s == null) {
                                break;
                            } else {
                                String[] array = s.split(" ");
                                map1.put(array[0], Integer.parseInt(array[1]));

                            }
                        }
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    int i = 1;
                    for(Map.Entry<String,Integer> entry : map1.entrySet()) {
                        i ++;
                        System.out.print(entry.getKey() + " ");
                        if(i % 5 == 0) {
                            System.out.print('\n');
                        }
                    }
                    System.out.println();
                    System.out.println("请输入您选择好的省份....");
                    String s = scanner.nextLine();

                    System.out.println("请输入你要旅行的天数");
                    int day = sc.nextInt();
                    System.out.println("为您计算资金");

                    System.out.println("...正在为您展示地图信息");
                    System.out.println("...即将得出所需资金");
                    int money = map1.get(s) * day * 2 + 160;
                    System.out.println("您所需要准备的资金为：" + money + "元");
                    System.out.println("祝您旅途愉快！！！（按回车键继续）");

                    String s7 = scanner.nextLine();
                    System.out.println("制作小组：第八组（按回车键继续）");
                    String s8 = scanner.nextLine();
                    break;
            }
        }


    }

}
